package com.mszlu.blog.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mszlu.blog.admin.entity.Admin;
import com.mszlu.blog.admin.entity.Permission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AdminMapper extends BaseMapper<Admin> {

    @Select("SELECT * FROM ms_permission WHERE id in (SELECT permission_id FROM ms_admin_permission WHERE admin_id=#{id})")
    List<Permission> findPermissionByAdminId(Long id);

    @Update("update ms_admin set password = #{password} where username = #{username}")
    int updateByUserName(Admin admin);
}
